package com.work.facade.impl;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import org.jboss.logging.Logger;

import com.work.dao.UserDAO;
import com.work.dto.UserDto;
import com.work.facade.UserFacade;
import com.work.model.User;

/**
 * The Class UserFacadeImpl.
 *
 * @author "Mihai Roman"
 */
@Stateless
public class UserFacadeImpl implements UserFacade {
	
	/** The Constant LOG. */
	private static final Logger LOG = Logger.getLogger(UserFacadeImpl.class);
	
	/** The user dao. */
	@EJB
	private UserDAO userDAO;

	@Override
	public void save(User user) {
		userDAO.save(user);
	}	

	public void saveUser(UserDto userDto) {
		User user = new User();
		user.setFirstName(userDto.getDtoFirstName());
		user.setLastName(userDto.getDtoLastName());
		user.setCk(userDto.getDtoCK());
		user.setCreatedBy(userDto.getDtoCreatedBy());
		user.setCreationDate(userDto.getDtoCreationDate());
		user.setUpdatedBy(userDto.getDtoUpdatedBy());
		user.setUpdatedDate(userDto.getDtoUpdatedDate());
		user.setRole(userDto.getDtoRole());
		user.setPassword("password");
		userDAO.save(user);
	}

	@Override
	public void delete(User user) {
		 userDAO.delete(user);
	}

	@Override
	public void deleteUser(UserDto userDto) {
	}

	@Override
	public User update(User newUser) {
		return userDAO.update(newUser);
	}

	@Override
	public UserDto update(UserDto newUserDto) {		
		return newUserDto;
	}

	@Override
	public List<User> findAll() {
		return userDAO.findAll();
	}	
}